import odoo from '@/odoo'

const model = 'account.move'
const namespace = 'accountMove'

const fields_default = {
  line_ids: {
    account_id: {},
    sub_account_id: {},
  }
}

const dvamodel = odoo.dvamodel({
  model, fields: fields_default
})

const {state, effects, reducers} = dvamodel

const Model = odoo.env(model);

export default {
  namespace,
  state,
  effects: {
    ...effects,

    *refresh({payload}, { call, put }) {
      const { id,fields=fields_default } = payload;
      const data = yield Model.browse(id,fields  );
      yield put({ type: 'save_one', payload: { data, fields } });
    },

    *unpost({payload}, { call, put }) {
      yield put({ type: 'button_cancel', payload });
    },

  },
  reducers:{
    ...reducers,

  }

};

